package com.slz3.business.module.memberManagement.userScoreRecord.service;

import com.slz3.business.frame.module.Repositorys;
import com.slz3.business.module.memberManagement.userScoreRecord.domain.UserScoreRecord;
import com.slz3.business.module.memberManagement.userScoreRecord.domain.UserScoreRecordFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Slf4j
@Service
public class UserScoreRecordTransactionalServiceImpl implements UserScoreRecordTransactionalService {

    @Override
    public UserScoreRecord modify(UserScoreRecord userScoreRecordNew) {
        Repositorys.userScoreRecord.test();
        Repositorys.userScoreRecord.save(UserScoreRecordFactory.initBaseFields());
        System.err.println(1/0);
        userScoreRecordNew.setLastModifyTime(LocalDateTime.now());
        return Repositorys.userScoreRecord.saveAndFlush(userScoreRecordNew);
    }

    @Override
    public List<UserScoreRecord> batchModify(List<UserScoreRecord> userScoreRecordList) {
        return Repositorys.userScoreRecord.saveAll(userScoreRecordList);
    }
}
